﻿/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Page1={
    create:function () {
    var page={};
        page.ui=new PIXI.DisplayObjectContainer();
        var bg=new PIXI.Sprite(resource['assets/images/p1_bg.png'].texture);
        page.ui.addChild(bg);

        var t0=new PIXI.Sprite(resource['assets/images/p1_t0.png'].texture);
        t0.anchor.set(0.5);
        t0.x = 370;
        t0.y =100;
        page.ui.addChild(t0);

        var t1=new PIXI.Sprite(resource['assets/images/p1_t1.png'].texture);
        t1.anchor.set(0.5);
        t1.x = 374;
        t1.y = 400;
        page.ui.addChild(t1);

        //var t2=new PIXI.Sprite(resource['assets/images/p1_t2.png'].texture);
        //t2.anchor.set(0.5);
        //t2.x = 382;
        //t2.y = 346;
        //page.ui.addChild(t2);
        var style = new PIXI.TextStyle({
            fontSize: 60,
            fontWeight: 'bold',
            fill: ['#BF9164', '#BF9164'], // gradient
            wordWrap: true,
            wordWrapWidth: 440
        });

        var t2 = new PIXI.Text(textName, style);
        t2.anchor.set(0.5,0.5);
        t2.x = 388;
        t2.y = 707;
        page.ui.addChild(t2);

        var t3=new PIXI.Sprite(resource['assets/images/p1_t3.png'].texture);
        t3.anchor.set(0.5);
        t3.x = 384;
        t3.y = 795;
        page.ui.addChild(t3);

        var t4=new PIXI.Sprite(resource['assets/images/p1_t4.png'].texture);
        t4.anchor.set(0.5);
        t4.x = 388;
        t4.y = 944;
        // t4.interactive=true;
        // t4.on('pointertap',function () {
        //     window.location.href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI0MDQ4MTY4Nw==&scene=110#wechat_redirect";
        // })
        // page.ui.addChild(t4);

        var t5=new PIXI.Sprite(resource['assets/images/p1_t5.png'].texture);
        t5.anchor.set(0.5);
        t5.x = 386;
        t5.y = 1074;
        page.ui.addChild(t5);

        page.In=function(){
            console.log('sadasdasdasd',textName);
            if(textName=='')
            {
                textName='无名';
                console.log('sadasdasdasd',textName);
            }
            t2.text=textName;

            bg.alpha=0;
            TweenMax.to(bg,1,{delay:0.2*0,alpha:1,ease:Linear.easeNone});

            t0.scale.x=t0.scale.y=0;
            t1.scale.x=t1.scale.y=0;
            t2.scale.x=t2.scale.y=0;
            t3.scale.x=t3.scale.y=0;
            t4.scale.x=t4.scale.y=0;
            t5.scale.x=t5.scale.y=0;
            TweenMax.to(t0.scale,1,{delay:0.2*1,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t1.scale,1,{delay:0.2*2,x:1,y:1,ease:Cubic.easeOut});
            TweenMax.to(t2.scale,1,{delay:0.2*3,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t3.scale,1,{delay:0.2*4,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t4.scale,1,{delay:0.2*5,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t5.scale,1,{delay:0.2*6,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t5.scale,1,{delay:2+0.2*6,x:1,y:1,ease:Back.easeOut});

            document.getElementById('img_qr').style.zIndex=15;
            document.getElementById('img_qr').style.opacity=0;
            TweenMax.to( document.getElementById('img_qr').style,1,{delay:0.2*5,opacity:1,ease:Back.easeOut});

            setTimeout(function()
            {
                TweenMax.to(t1.scale,1,{x:0.95,y:0.95,repeat:-1,yoyo:true,ease:Cubic.easeInOut});
            },1500)

            setInterval(function()
            {
                circleDownHandler();
            },1000);
        }

        function circleDownHandler(e) {

                 for(var i=0;i<8;i++)
                 {
                     var circle=Circle.create(230,0);
                     page.ui.addChild(circle.ui);

                     circle.ui.x=740/2-50;
                     circle.ui.y=400;

                     //arr_circle.push(circle);

                     circle.ui.scale.x=0;
                     circle.ui.scale.y=0;
                     TweenMax.to(circle.ui,2,{delay:0.1*i,alpha:0});
                     TweenMax.to(circle.ui.scale,2,{delay:0.1*i,x:1,y:1,onCompleteParams:[circle],onComplete:function (c) {
                         c.ui.parent.removeChild(c.ui);
                         c=null;
                         //arr_circle.splice(arr_circle.indexOf(c),1);
                         //console.log(arr_circle.length);
                     }});

                 }

            for(var i=0;i<8;i++)
            {
                var circle=Circle.create(-230,0);
                page.ui.addChild(circle.ui);

                circle.ui.x=740/2;
                circle.ui.y=400;

                //arr_circle.push(circle);

                circle.ui.scale.x=0;
                circle.ui.scale.y=0;
                TweenMax.to(circle.ui,2,{delay:0.1*i,alpha:0});
                TweenMax.to(circle.ui.scale,2,{delay:0.1*i,x:1,y:1,onCompleteParams:[circle],onComplete:function (c) {
                    c.ui.parent.removeChild(c.ui);
                    c=null;
                    //arr_circle.splice(arr_circle.indexOf(c),1);
                    //console.log(arr_circle.length);
                }});

            }

            for(var i=0;i<0;i++)
            {
                var circle=Circle.create(0,250);
                page.ui.addChild(circle.ui);

                circle.ui.x=740/2;
                circle.ui.y=400-100;

                //arr_circle.push(circle);

                circle.ui.scale.x=0;
                circle.ui.scale.y=0;
                TweenMax.to(circle.ui,2,{delay:0.1*i,alpha:0});
                TweenMax.to(circle.ui.scale,1.5,{delay:0.1*i,x:0.5,y:0.65,onCompleteParams:[circle],onComplete:function (c) {
                    c.ui.parent.removeChild(c.ui);
                    c=null;
                    //arr_circle.splice(arr_circle.indexOf(c),1);
                    //console.log(arr_circle.length);
                }});

            }

            for(var i=0;i<0;i++)
            {
                var circle=Circle.create(0,-250);
                page.ui.addChild(circle.ui);

                circle.ui.x=740/2;
                circle.ui.y=400+100;

                //arr_circle.push(circle);

                circle.ui.scale.x=0;
                circle.ui.scale.y=0;
                TweenMax.to(circle.ui,2,{delay:0.1*i,alpha:0});
                TweenMax.to(circle.ui.scale,1.5,{delay:0.1*i,x:0.5,y:0.65,onCompleteParams:[circle],onComplete:function (c) {
                    c.ui.parent.removeChild(c.ui);
                    c=null;
                    //arr_circle.splice(arr_circle.indexOf(c),1);
                    //console.log(arr_circle.length);
                }});

            }

        }


    return page;
    }
}